package com.ebs.md.api.abs;

/**
 * Revision Author:
 *  $File: //depot/MarketData/commons-md-api/MAIN/src/main/java/com/ebs/md/api/abs/PrefixedLogger.java $
 *  $Revision: #1 $
 *  $DateTime: 2012/05/15 09:58:52 $
 *  $Change: 111052 $
 *  $Author: Arik.Sher $
 */

import org.apache.log4j.Logger;

/**
 *
 * 
 * Note: because Logger and Category do implement any notable interface, 
 * this delegate is BYNAME delegate and not natural polymorphism
 */
public class PrefixedLogger
{
	final protected Logger delegate;
	final protected String prefix;

	public PrefixedLogger(Logger delegate, String prefix) {
		this.delegate = delegate;
		this.prefix   = prefix;
	}

	protected Object decorateMessage(Object originalMessage) {
		return prefix + originalMessage;
	}
	
	public void debug(Object message, Throwable t) {
		delegate.debug(decorateMessage(message), t);
	}

	public void debug(Object message) {
		delegate.debug(decorateMessage(message));
	}

	public void error(Object message, Throwable t) {
		delegate.error(decorateMessage(message), t);
	}

	public void error(Object message) {
		delegate.error(decorateMessage(message));
	}

	public void fatal(Object message, Throwable t) {
		delegate.fatal(decorateMessage(message), t);
	}

	public void fatal(Object message) {
		delegate.fatal(decorateMessage(message));
	}

	public void info(Object message, Throwable t) {
		delegate.info(decorateMessage(message), t);
	}

	public void info(Object message) {
		delegate.info(decorateMessage(message));
	}

	public boolean isDebugEnabled() {
		return delegate.isDebugEnabled();
	}

	public boolean isInfoEnabled() {
		return delegate.isInfoEnabled();
	}

	public boolean isTraceEnabled() {
		return delegate.isTraceEnabled();
	}

	public void trace(Object message, Throwable t) {
		delegate.trace(decorateMessage(message), t);
	}

	public void trace(Object message) {
		delegate.trace(decorateMessage(message));
	}

	public void warn(Object message, Throwable t) {
		delegate.warn(decorateMessage(message), t);
	}

	public void warn(Object message) {
		delegate.warn(decorateMessage(message));
	}
	
}
